Parser Rules
The router will only match the URL
paths
, notquery strings
orsearch parameters
&hash
oranchor
.The paths will always be matched case-insensitively.
Eg:
/about
is same as/About
.The trailing slash
/
will not be matched by default.Eg: The route
/docs
will match path/docs
but not/docs/
.A route segment can have
named
orunnamed
orboth
the parameters.The parameters name must be defined by prefixing the colon
:
character to the name.Eg:
/users/:userID
, here theuserID
is the parameter name.The parameters name must match this regular expression
[A-Za-z0-9_]
.The named parameters match their value using this regular expression
([^/]+)
.The named parameters default matching can be overridden by the
custom
regular expressions, the custom regex must be defined by suffixing(regexp)
to the name.Eg:
/orders/:orderId(\d+)
, here the paramorderID
matches only the digits.The unnamed parameters must be defined by
custom
regular expressions.Eg:
/photos/(.*)
can match paths like/photos/my-family.jpg
,/photos/selfie.png
.The regexp
caputring groups
are not allowed inside thecustom
regexp.Eg: This will throw an error
/photos/(.*.(jpg|png))
. But this will not throw an error/photos/(.*).(jpg|png)
.The modifiers
*
,+
, and?
must be placed after the parameter.Eg:
/:chapters*
,/(.*)+
,/docs/:slug?